
﻿using Aop.Api.Domain;
using Microsoft.AspNetCore.Http;

﻿using Microsoft.AspNetCore.Http;

using Microsoft.AspNetCore.Mvc;
using NETCore.Encrypt;
using System.Reflection.Metadata.Ecma335;

namespace WorkOne.Webapi.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class EncryptController : ControllerBase
    {
        [HttpGet("Aes")]
        public IActionResult actionResult(string plaintext1, string iv1)
        {
            var plaintext = "feawfweaf";//希望加密的字符串
            string key = "asdfghjklqwertyuiopzxcvbnmzxcvll";//32位随机值0-9,a-z,A-Z
            string iv = "1234567812345678";//16位随机值0-9,a-z,A-Z
            var encrypted = EncryptProvider.AESEncrypt(plaintext, key);//加密
            var decrypted = EncryptProvider.AESDecrypt(encrypted, key);//解密

            return Ok(1);
        }
        /// <summary>
        /// 测试
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        [HttpGet("aa")]
        public IActionResult aa(int a,int b)
        {
            return Ok(a / b);
        }

        [HttpGet("bb")]
        public IActionResult bb(int b,int c)
        {
            return Ok(b*c);
        }
        /// <summary>
        /// 江建浩测试
        /// </summary>
        /// <param name="b"></param>
        /// <param name="c"></param>
        /// <returns></returns>
        [HttpGet("cc")]
        public IActionResult cc(int b, int c)
        {
            return Ok(b+c);
        }
        [HttpGet("dd")]
        public IActionResult dd(int b, int c)
        {
            return Ok(b - c);
        }
        
        [HttpGet]
        public IActionResult abc(int b, int c)
        {
            return Ok(b - c);
        }

        /// <summary>
        /// 郭佳测试666
        /// </summary>
        /// <returns></returns>
        [HttpGet("Demo")]
        public IActionResult Demo()
        {
            List<string> list = new List<string>();
            string[] strings = { "春", "夏", "秋", "冬", "金", "木", "水", "火", "土", "帅", "小", "伙" };
            for (int i = 0; i < 6; i++)
            {
                Random random = new Random();
                int randomNumber = random.Next();
                int firstDigit = Math.Abs(randomNumber % 10);
                list.Add(strings[firstDigit]);
            }
            return Ok(list);
        }

        
        /// <summary>
        /// 新增Result
        /// </summary>
        /// <returns></returns>
        [HttpPost("AddResult")]
        public IActionResult AddResult()
        {
            return Ok("DemoNOT");
        }



        /// <summary>
        /// 郭佳测试
        /// </summary>
        /// <returns></returns>
        [HttpGet("Demo1")]
        public IActionResult Demo1()
        {
            return Ok("Demo1NOT");
        }


        /// <summary>
        /// 郭佳测试
        /// </summary>
        /// <returns></returns>
        [HttpGet("Demo2")]
        public IActionResult Demo2()
        {
            return Ok("Demo2NOT");
        }


        /// <summary>
        /// 郭佳测试6
        /// </summary>
        /// <returns></returns>
        [HttpGet("Demo3")]
        public IActionResult Demo3()
        {
            return Ok("Demo3NOT");
        }
        /// <summary>
        /// 芜湖（周）
        /// </summary>
        /// <returns></returns>
        [HttpGet("CreateResult")]
        public IActionResult CreateResult()
        {
            string str = "芜湖NOT";
            return Ok(str);
        }
        //递归（周）
        [HttpGet("factorial")]
        public IActionResult factorial(int n)
        {
            if (n == 0 || n == 1)
            {
                return Ok(1);
            }
            // 递归情况 - 通过递归调用自身来计算阶乘
            int result = CalculateFactorial(n);
            return Ok(result);
        }
        //随机数（周）
        [HttpGet("RandomNumber")]
        public IActionResult RandomNumber(int min, int max)
        {
            Random random = new Random();
            int randomNumber = random.Next(min, max + 1);
            return Ok(randomNumber);
        }
        //递归（周）
        private int CalculateFactorial(int n)
        {
            if (n == 0 || n == 1)
            {
                return 1;
            }
            return n * CalculateFactorial(n - 1); // 递归调用
        }
        /// <summary>
        /// 赵向前删除Result测试
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// 
        [HttpGet("Delete")]
        public IActionResult Delete(int id)
        {
            var i = 1;
            return Ok(i);
        }
        /// <summary>
        /// 江东霖合并测试
        /// </summary>
        /// <returns></returns>

        public IActionResult Update()
        {
            return Ok("haha");
        }


        /// <summary>
        /// 郭佳  测试新建分支   修改注释测试分支合并
        /// </summary>
        /// <returns></returns>
        [HttpGet("guojia")]
        public IActionResult GetFenzhi()
        {
            return Ok("111");
        }


        /// <summary>
        /// 购买数量
        /// </summary>
        /// <returns></returns>
        [HttpGet("GetShop")]
        public IActionResult GetShop()
        {
            return Ok("张三买了个笔记本");
        }
        [HttpDelete("Delete")]
        public IActionResult GetShop1()
        {
            return Ok("张三买了个笔记本");
        }
    }
}